<#import "/admin/_layout.html" as layout>
<@layout.header "插件管理"></@layout.header>
<@layout.body>
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-left">
                        <li class="breadcrumb-item"><a href="#">插件</a></li>
                        <li class="breadcrumb-item active">列表</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <section class="content">
    <div class="container-fluid">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <a href="/admin/plugin/install" class="btn btn-info"><i class="fas fa-plus"></i> 安装</a>
                </div>
                <table class="table table-hover" style="width:100%">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>插件版本</th>
                        <th>插件路径</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <#list plugins as item>
                        <tr>
                            <td>${item.descriptor.pluginId!}</td>
                            <td>${item.descriptor.version!}</td>
                            <td>${item.pluginPath!}</td>
                            <td>${item.pluginState!}</td>
                            <td><a class="unInstall_a" href="javascript:void(0)" id="${item.descriptor.pluginId!}">卸载</a></td>
                        </tr>
                    </#list>
                </table>
            </div>
        </div>
    </div>
    </section>
</@layout.body>
<@layout.script>
    <script type="text/javascript">
        $(document).ready(function() {
            $(".unInstall_a").click(function() {
                var pluginId = $(this).attr("id");
                layer.confirm('确定要卸载['+pluginId+']插件吗?', {
                    btn : ['确定', '取消']
                }, function(i) {
                    layer.close(i);
                    ajaxPost("/admin/plugin/doUnInstall", {pluginId: pluginId}, function () {
                        alertSuccess("卸载成功", function(){
                            location.href = "/admin/plugin/list";
                        })
                    })
                });
            })
        });
    </script>
</@layout.script>